import java.awt.Graphics;
import java.awt.Point;


public class Edge
{
	public Node to;
	public Node from;
	// TODO use this for something.
	public double cost;
	
	public Edge(Node to, Node from, double cost)
	{
		this.to = to;
		this.from = from;
		this.cost = cost;
	}
	
	public void draw(Graphics g)
	{
		if(to instanceof Circle 
		&& from instanceof Circle)
		{
			Circle ct = ((Circle)to), cf = ((Circle)from);
			Point t = ct.edgeToward(cf.center);
			Point f = cf.edgeToward(ct.center);
			g.drawLine(t.x, t.y, f.x, f.y);
			int dx = f.x-t.x;
			int dy = f.y-t.y;
			double dist = Math.sqrt(dx*dx+dy*dy);
			int size = 5;
			dx = (int)(dx * size / dist);
			dy = (int)(dy * size / dist);
			int bx = t.x+dx;
			int by = t.y+dy;
			int wx = bx-dy;
			int wy = by+dx;
			g.drawLine(t.x, t.y, wx, wy);
			wx = bx+dy;
			wy = by-dx;
			g.drawLine(t.x, t.y, wx, wy);
		}
	}
}
